#docker build -t 192.168.0.226/feishuwg/p2p:latest -f http://192.168.0.237/feishu/feishup2pclient/-/raw/main/Dockerfile . --platform=linux/amd64,linux/386,linux/arm/v7,linux/arm64/v8 --no-cache
##docker build -t 192.168.0.226/feishuwg/p2p:latest -f http://192.168.0.237/feishu/feishup2pclient/-/raw/main/Dockerfile . --platform=linux/amd64,linux/arm64/v8 --no-cache --push


FROM 192.168.0.226/feishuwg/golang:18 AS buildx
#时间时区
RUN apk add --no-cache tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone \
    && apk del tzdata
WORKDIR /go
RUN git clone  http://192.168.0.237/feishu/feishup2pclient.git && \
 wget  http://192.168.0.170:9000/test/.s3cfg -P /root/
# COPY . feishup2pclient
WORKDIR /go/feishup2pclient
RUN go env -w GOPROXY=http://192.168.0.227:8081/repository/goproxy/ && \
    go mod download && \
	 go mod tidy -compat=1.18 && \
	 go env -w CGO_ENABLED=0 && go env -w GO111MODULE=on
RUN     export vnow=$(date "+%Y-%m-%d-%H:%M:%S") && echo $vnow && go build -ldflags "-s -w -X main.buildV=$vnow" -a -o $GOPATH/vpn-feishu-p2p .
#    apk update && apk add libpcap-dev gcc && \
#    apk --no-cache --update add build-base && \
RUN s3cmd put  /go/vpn-feishu-p2p s3://feishup2p/$(uname -s)-$(uname -m)/






FROM alpine:3.18
WORKDIR /
#时间时区
RUN apk add --no-cache tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && echo "Asia/Shanghai" > /etc/timezone \
    && apk del tzdata
COPY --from=buildx /go/feishup2pclient/start.sh .
COPY --from=buildx /go/vpn-feishu-p2p .

RUN chmod +x /start.sh

CMD ["sh","/start.sh"]
